/*
    Copyright (C) 2013 maik.jablonski@jease.org

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package sample.web.task.status;

import sample.domain.Status;
import jfix.zk.Radiobutton;
import jfix.zk.Radiogroup;

public class Statusfield extends Radiogroup {

	Radiobutton accepted = new Radiobutton("Accepted");
	Radiobutton started = new Radiobutton("Started");
	Radiobutton done = new Radiobutton("Done");
	Radiobutton duplicate = new Radiobutton("Duplicate");
	Radiobutton invalid = new Radiobutton("Invalid");
	Radiobutton wontfix = new Radiobutton("Wont Fix");

	public Statusfield() {
		appendChild(accepted);
		appendChild(started);
		appendChild(done);
		appendChild(duplicate);
		appendChild(invalid);
		appendChild(wontfix);
	}

	public void setValue(Status status) {
		accepted.setChecked(status.isAccepted());
		started.setChecked(status.isStarted());
		done.setChecked(status.isDone());
		duplicate.setChecked(status.isDuplicate());
		invalid.setChecked(status.isInvalid());
		wontfix.setChecked(status.isWontfix());
	}

	public Status getValue() {
		Status status = new Status();
		status.setAccepted(accepted.isChecked());
		status.setStarted(started.isChecked());
		status.setDone(done.isChecked());
		status.setDuplicate(duplicate.isChecked());
		status.setInvalid(invalid.isChecked());
		status.setWontfix(wontfix.isChecked());
		return status;
	}

}
